#! /bin/make -f
# @file
# @brief Makefile规则：cppcheck
# @author
# + 隐星魂 (Roy Sun) <xwos@xwos.tech>
# @copyright
# + Copyright © 2015 xwos.tech, All Rights Reserved.
# > Licensed under the Apache License, Version 2.0 (the "License");
# > you may not use this file except in compliance with the License.
# > You may obtain a copy of the License at
# >
# >         http://www.apache.org/licenses/LICENSE-2.0
# >
# > Unless required by applicable law or agreed to in writing, software
# > distributed under the License is distributed on an "AS IS" BASIS,
# > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# > See the License for the specific language governing permissions and
# > limitations under the License.
#

MSG := echo -e
CPPCHECK := cppcheck
J ?= 1
CPPCHECK_CLANG ?= $(XWTC)/armllvm/bin/clang --sysroot=$(XWTC)/armllvm/lib/clang-runtimes/arm-none-eabi/$(SYSROOT_llvm)
CPPCHECK_OUT ?= $(XWOS_WKSPC_DIR)/cppcheck
CPPCHECK_INCDIRS = -I. -I$(XWOS_ARCH_DIR) -I$(XWOS_CPU_DIR) -I$(XWOS_SOC_DIR) -I$(XWOS_BRD_DIR)
CPPCHECK_FLAGS = --force --addon=misra --cppcheck-build-dir=$(CPPCHECK_OUT) --template=gcc -j$(J)
CPPCHECK_FLAGS += --inline-suppr --suppressions-list=xwbs/misra-c2012-suppressions.txt
CPPCHECK_FLAGS += $(ARCH_CPPCHECK_FLAGS)
CPPCHECK_FLAGS += $(CPU_CPPCHECK_FLAGS)
CPPCHECK_FLAGS += $(SOC_CPPCHECK_FLAGS)
CPPCHECK_FLAGS += $(BRD_CPPCHECK_FLAGS)
ifeq ($(XWCFG_CORE),mp)
  CPPCHECK_FLAGS += -i xwos/up
endif
ifeq ($(XWCFG_CORE),up)
  CPPCHECK_FLAGS += -i xwos/mp
endif

ifeq ($(XWCFG_HOSTOS),gnu/linux)
  ifneq ($(V),1)
    SHOW_CPPCHECK = @$(MSG) "\e[1m\e[44;38m[cppcheck] "$*" \e[0m";
  endif
endif

ifeq ($(XWCFG_HOSTOS),darwin)
  ifneq ($(V),1)
    SHOW_CPPCHECK = @$(MSG) "\e[1m\e[44;38m[cppcheck] "$*" \e[0m";
  endif
endif

ifeq ($(XWCFG_HOSTOS),windows-nt)
  ifneq ($(V),1)
    SHOW_CPPCHECK = @$(MSG) "[cppcheck] "$* ;
  endif
endif
